package com.code260.ss.guice.demo.bill;

import com.google.inject.name.Named;

import javax.inject.Inject;

public class RealBillingService implements BillingService  {

    private TransactionLog transactionLog;

    private CreditCardProcessor creditCardProcessor;

    private int chargeTimeout = 100;

    private AlertService alertService;

    /**
     * 3. 打上需要注入的标签
     * @param transactionLog
     * @param creditCardProcessor
     */
    @Inject
    public RealBillingService(TransactionLog transactionLog, @PayPal CreditCardProcessor creditCardProcessor,
                              @Named("chargeTimeout") int chargeTimeout, AlertService alertService) {
        this.transactionLog = transactionLog;
        this.creditCardProcessor = creditCardProcessor;
        this.chargeTimeout = chargeTimeout;
        this.alertService = alertService;
    }

    @NonWeekend
    public void chargeOrder(PizzaOrder order, CreditCard creditCard) {
        System.out.println(transactionLog.getClass());
        System.out.println(creditCardProcessor.getClass());
        System.out.println(this.chargeTimeout);
        System.out.println(alertService);
    }
}
